package com.wyh.book.mapper;

import com.wyh.book.model.BookInfo;
import com.wyh.book.model.PageInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-07-12
 * Time: 12:35
 */
@Mapper
public interface BookInfoMapper {
    Integer insertBook(BookInfo bookInfo);

//    @Select("select * from book_info")
    List<BookInfo> selectAll();

    @Select("SELECT * FROM book_info WHERE `status` != 0 LIMIT #{offset},#{pageSize}")
    List<BookInfo> getListByPage(PageInfo page);

    @Select("SELECT count(1) FROM book_info WHERE `status` != 0")
    Integer getCount();

    @Select("select * from book_info where id = #{id} and `status` != 0")
    BookInfo selectById(Integer id);

    Integer updateBook(BookInfo bookInfo);

    @Update("update book_info set `status` = 0 where id = #{id}")
    void deleteBook(Integer id);

    Integer batchDelete(List<Integer> ids);
}
